package tech.aistar.mapper.guidemapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tech.aistar.entity.daoyou.GuideApply;
import tech.aistar.entity.daoyou.GuideInfo;
import tech.aistar.entity.daoyou.GuideRoute;
import tech.aistar.entity.person_center.Orders;

import java.util.List;

/**
 *
 */
public interface GuideHome {

    //通过用户得id 来插曲用户得信息
    @Select("select sex from user_idcard where user_id=${value} ")
    String getUserById(Integer id);

    //通过用户导游申请表
    @Select("select * from guide_info where guide_id =${value}")
    GuideInfo getGuideInfo(Integer id);

    //查看该用户是否是导游 查看得是导游申请表
    @Select("select * from guide_apply where user_id=${value} and apply_status =1")
    GuideApply SelectGuideById(Integer id);


    //获取该导游的预约表
    @Select("select * from orders where guide_id =${id} and order_status=0 and '${apply_time}'<= apply_time ")
    List<Orders> getBill(@Param("id") Integer id, @Param("apply_time") String apply_time);


    //通过id 获取Ordera中的信息 有问题
    @Select("select * from orders where id=${value}")
    Orders  getOrdersById(Integer id);

    @Select( "select * from orders where order_status=1 and  apply_time >o.apply_name ")
    Orders checkOrder(Orders o);

    //通过账单id来获取账单信息
@Select("select * from orders where id=${value} ")
Orders getBillById(Integer id);

    //导游接单
    @Update("update orders set order_status=1 where id=${value}")
    void accessBill(Integer id);

    //导游拒绝订单
    @Update("update orders set order_status=-2 where id=${value}")
    void delBill(Integer id);


    //查看导游的接单
    //可以随意预约,不可重复接单
    @Select("select * from orders where order_status=1 and guide_id =${value}")
    List<Orders> getAllBill(Integer id);
    //不可以随意预约
//    @Select("select * from orders where order_status in(0,1) and guide_id = ${value}")




    //查询路线
    @Select("select * from guide_route where guide_id=${value} ")
    GuideRoute getAllRoutById(Integer id);
   //新建路线
    @Insert("insert into guide_route (guide_id,guide_text) values(${id},'${text}')")
    void inserRout(@Param("id") Integer id,@Param("text") String  text);
    //更改路线
    @Update("update  guide_route set guide_text ='${text}'  where guide_id=${id}")
    void gupdateRoutById(@Param("id") Integer id,@Param("text") String  text);

    //更换自己的状态
    @Update("update  guide_info set status =${stare}  where id=${id}")
    void setGuideState(@Param("id") Integer id,@Param("stare") Integer stare);


    //导游取消订单
    @Update("update  orders set order_status=-1  where id=${value}")
    void setOrders( Integer id);

    //导游的分数减少
    @Update("update guide_info set reputation=reputation-10 where id=${value}")
    void setGuideScore(Integer id);


}
